
%--------------------PM-Square---start-----------------
clc;
close all
clear all

f0=1;                                               %调制信号频率
fs=10;                                               %采样频率，大于两倍时间采样频率
N=2001;


n=0:N-1;t=n/fs;  %时间序列


beta=5.*pi./2;                                      %调制深度
fc=10e6;                                          %载波频率
t1=cos(2.*pi.*fc*t);                           %载波
pm=0.5.*square(2.*pi.*f0*t);             %信息信号，或调制信号  square为方波信号
plot(pm(0:20));
% 
% 
% s_pm1=exp(1i.*(2.*pi.*fc.*t+3.14159./2.*pm));%+ randn(size(t))/10;  %randn(n)：产生n个随机数 
% s_pm2=exp(1i.*(2.*pi.*fc.*t+3.14159.*pm));%+ randn(size(t))/10; %size(t)：t的个数
% 
% s_pm3=exp(1i.*(2.*pi.*fc.*t+2.*3.14159./2.*pm));%+ randn(size(t))/10;
% s_pm4=exp(1i.*(4.*pi.*fc.*t+4.*3.14159./2.*pm));%+ randn(size(t))/10;
% 
% s_pm5=exp(1i.*(2.*pi.*fc.*t));%+ randn(size(t))/10;
% s_pm6=exp(1i.*(4.*pi.*fc.*t));%+ randn(size(t))/10;
% 
% PM1=fft(pm);
% T1=fft(t1); 
% PM=fftshift(fft(fftshift(pm)))./N; %fftshift(X) 通过将零频率分量移动到阵列的中心来重新排列傅立叶变换 X。
% pm_fft=ifftshift(fft(fftshift(pm)))./N;
% 
% S_PM1=fftshift(fft(fftshift(s_pm1)))./N;
% S_PM2=fftshift(fft(fftshift(s_pm2)))./N;
% 
% S_PM3=fftshift(fft(fftshift(s_pm3)))./N;
% S_PM4=fftshift(fft(fftshift(s_pm4)))./N;
% 
% S_PM5=fftshift(fft(fftshift(s_pm5)))./N;
% S_PM6=fftshift(fft(fftshift(s_pm6)))./N;
% 
% I_PM=abs(PM).^2;
% 
% 
% I_PM1=abs(S_PM1).^2;  %I=PM^2 表示振幅
% I_PM2=abs(S_PM2).^2;
% I_PM3=abs(S_PM3).^2;
% I_PM4=abs(S_PM4).^2;
% I_PM5=abs(S_PM5).^2;
% I_PM6=abs(S_PM6).^2;
% 
% 
% f_nor=(0:N-1)*fs/N-fs/2;
% figure(1)
% plot(f_nor,I_PM);
% 
% figure(2)
% plot(f_nor,I_PM1);
% title('Spectrum of Fundamental Laser  {\gamma}={\pi}/2','FontName','Times New Roman','FontWeight','Bold');
% xlabel('Normalized Frequency');ylabel('Spectral Power [a. u.]');
% save('data2.mat','f_nor','I_PM1');
% 
% figure(3)
% plot(f_nor,I_PM2,'color','k');
% title('Spectrum of Second Harmonic {\gamma}={\pi}','FontName','Times New Roman','FontWeight','Bold');
% xlabel('Normalized Frequency');ylabel('Spectral Power [a. u.]');
% 
% figure(4);
% plot(f_nor,I_PM3);
% title('Spectrum of Fundamental Laser {\gamma}={\pi}','FontName','Times New Roman','FontWeight','Bold');
% xlabel('Normalized Frequency');ylabel('Spectral Power [a. u.]');
% 
% figure(5)
% plot(f_nor,I_PM4,'color','k');
% title('Spectrum of Second Harmonic {\gamma}=2{\pi}','FontName','Times New Roman','FontWeight','Bold');
% xlabel('Normalized Frequency');ylabel('Spectral Power [a. u.]');
% 
% figure(6)
% plot(f_nor,I_PM5);
% title('Spectrum of Fundamental Laser {\gamma}=0','FontName','Times New Roman','FontWeight','Bold');
% xlabel('Normalized Frequency');ylabel('Spectral Power [a. u.]');
% 
% figure(7)
% plot(f_nor,I_PM6,'color','k');
% title('Spectrum of Second Harmonic {\gamma}=0','FontName','Times New Roman','FontWeight','Bold');
% xlabel('Normalized Frequency');ylabel('Spectral Power [a. u.]');
